//
//  FunctionButton.m
//  SDSY
//
//  Created by 蓝布鲁 on 2017/3/20.
//  Copyright © 2017年 蓝布鲁. All rights reserved.
//

#import "FunctionButton.h"

@interface FunctionButton()

@property (nonatomic,assign)FunctionButtonType type;       // btn的类型

@end

@implementation FunctionButton

#pragma mark - 自定义初始化方法
- (instancetype)initWithFrame:(CGRect)frame title:(NSString *)title backgroundImage:(UIImage *)backgroundImage buttonType:(FunctionButtonType)buttonType{
    if ([super initWithFrame:frame]) {
        // 1.设置标题
        [self setTitle:title forState:UIControlStateNormal];
        
        // 2.设置背景图片
        [self setBackgroundImage:backgroundImage forState:UIControlStateNormal];
        
        // 3.设置title颜色
        [self setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        
        // 4.保存btn的类型
        self.type = buttonType;
        
        // 5.调整字体大小
        self.titleLabel.font = [UIFont systemFontOfSize:15];
        
    }
    return self;
}

#pragma mark - 系统回调方法
- (void)layoutSubviews {
    [super layoutSubviews];

    CGRect frame = self.titleLabel.frame;
    
    
    switch (self.type) {
        case FunctionButtonBigVerticalType:        // 竖直方向大图标
            frame.origin.y = 10;
            self.titleLabel.frame = frame;
            break;
        case FunctionButtonBigHorizontalType:      // 水平方向大图标
            
            break;
        case FunctionButtonLittleVerticalType:      // 竖直方向小图标
            
            break;
        case FunctionButtonLittleHorizontalType:     // 水平方向小图标
            
            break;
        case FunctionButtonHalfVerticalType:     // 水平方向小图标
            frame.origin.y = self.frame.size.height - 25;
            self.titleLabel.frame = frame;
            break;
        
    }
    

    
}

@end
